/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {Text, View, Image, Dimensions, TouchableOpacity} from 'react-native';

import Common from '../../component/common';

import MoreIndustryMedia from './moreIndustryMedia';

import styles from '../../style/media';

import IndustryMediaList from './industryMediaList';

const totalWidth = Dimensions.get('window').width;

export default class IndustryMedia extends Component {
  constructor(props) {
    super(props);
  }
  render() {
    var data = this.props.data;
    var mm = Common.toTransformation(data.mmCurrentReportCount);
    // var rsSize = mm.length > 3 ? 16 : 20;
    return (
      <View>
        <View style={[styles.reportTitle,{height: totalWidth*0.158}]}>
          <TouchableOpacity onPress = {() => Common.onForward(this,MoreIndustryMedia,"today",data)} style={[styles.reportTitleW,{flex: 2,height:totalWidth*0.158,justifyContent: 'center',alignSelf: 'flex-start'}]}>
            <View style={[styles.reportTitleL, {marginLeft: totalWidth*0.01,alignSelf: 'center',height: totalWidth*0.074,borderRadius: totalWidth*0.037,paddingHorizontal: 5,backgroundColor:'#ffeeee',}]}>
              <View style={styles.reportTitleTextF}>
                <Text style={styles.reportTitleN}>
                  {mm.value}
                  <Text style={{fontSize: 8}}>{mm.unit}</Text>
                </Text>
                <Text style={styles.todayReport}>今日报道量</Text>
              </View>
            </View>
          </TouchableOpacity>
          <View style={{flex: 4,flexDirection: 'row',justifyContent: 'flex-end'}}>
            <TouchableOpacity onPress = {() => Common.onForward(this,MoreIndustryMedia,"yesterday",data)} style={[styles.reportTitleW,{height:totalWidth*0.158}]}>
              <Text style={styles.reportTitleN}>{Common.toTransformation(data.mmYesterdayReportCount).value}<Text style={styles.unitF}>{Common.toTransformation(data.mmYesterdayReportCount).unit}</Text></Text>
              <View style={styles.reportTitleL}>
                <Text style={styles.reportTitleText}>48小时</Text>
                <Text style={styles.reportTitleText}>报道量</Text>
              </View>
            </TouchableOpacity>
            <TouchableOpacity onPress = {() => Common.onForward(this,MoreIndustryMedia,"week",data)} style={[styles.reportTitleW,{height:totalWidth*0.158}]}>
              <Text style={styles.reportTitleN}>{Common.toTransformation(data.mmOther1ReportCount).value}<Text style={styles.unitF}>{Common.toTransformation(data.mmOther1ReportCount).unit}</Text></Text>
              <View style={styles.reportTitleL}>
                <Text style={styles.reportTitleText}>七日</Text>
                <Text style={styles.reportTitleText}>报道量</Text>
              </View>
            </TouchableOpacity>
            <TouchableOpacity onPress = {() => Common.onForward(this,MoreIndustryMedia,"history",data)} style={[styles.reportTitleW,{height:totalWidth*0.158}]}>
              <Text style={styles.reportTitleN}>{Common.toTransformation(data.mmTotalReportCount).value}<Text style={styles.unitF}>{Common.toTransformation(data.mmTotalReportCount).unit}</Text></Text>
              <View style={styles.reportTitleL}>
                <Text style={styles.reportTitleText}>历史总</Text>
                <Text style={styles.reportTitleText}>报道量</Text>
              </View>
            </TouchableOpacity>
          </View>
        </View>
        <IndustryMediaList data={data} {...this.props}/>
      </View>
    )
  }
}
